<?php
class Admin_CustomerController extends Apps_Controller_Action_Admin {

    public function readAction() {
	    $dbAdapter = Zend_Db_Table::getDefaultAdapter();
	    $select = $dbAdapter
            	    ->select()
            	    ->from('customer', null)
            	    ->where('customer.status =? ', Model_DbTable_Customer::STATUS_ACTIVE)
            	    ->columns(array(
            	            'id'        => 'customer.id',
            	            'full_name' => 'customer.full_name',
            	            'email'     => 'customer.email',
            	            'phone'     => 'customer.phone',
            	            'address'   => 'customer.address',
            	            'description'   => 'customer.description'
            	    ));

	    $grid = new Grid_Customer_Customer('grid-customer');
	    $grid->setCaption('List Customer');
	    $grid->setSource(new OeZend_Widget_Grid_Source_ZendDbSelect($select));
	    $grid->setView(new OeZend_Widget_Grid_View());
	    $grid->setDisablePaginator();

	    $grid->deploy();

	    $this->view->grid = $grid;
	}

    public function deleteAction() {
        $id = $this->_request->getParam('id');
        if(!$id) {
            $this->_redirect('read');
        }
        $tbCustomer = new Model_DbTable_Customer();
        $tbCustomer->safelyUpdate(array('status' => Model_DbTable_Customer::STATUS_DELETE), array('id =?' => $id));
        $this->_helper->redirector('read');
    }
}